<html>
<head><meta charset="utf-8"><title>cranelift backend · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html">cranelift backend</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213358864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213358864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213358864">(Oct 14 2020 at 22:37)</a>:</h4>
<p>There’s an accepted MCP to add a Cranelift backend to rustc and gate builds on it working. This will have some implications for us wanting to land portable SIMD based on LLVM intrinsics on <code>nightly</code>. We should look into what gaps might exist in <code>cg_clif</code>’s <code>simd_*</code> intrinsics that would prevent us from landing <code>core::simd</code>.</p>



<a name="213359076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213359076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213359076">(Oct 14 2020 at 22:39)</a>:</h4>
<p>Is Cranelift still just x86?</p>



<a name="213360234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360234">(Oct 14 2020 at 22:52)</a>:</h4>
<p>one option is to temporarily disable some functions on non-LLVM backends</p>



<a name="213360300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360300">(Oct 14 2020 at 22:53)</a>:</h4>
<p>I don't know about cg_clif, but cranelift itself also supports ARM (icr if it's aarch64 and/or armv7) and RISC-V</p>



<a name="213360421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360421">(Oct 14 2020 at 22:54)</a>:</h4>
<p>Is the intention of cranelift still just for debug?  I think we could write equivalents too all llvm intrinsics with plain rust (not SIMD) if we must</p>



<a name="213360467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360467">(Oct 14 2020 at 22:55)</a>:</h4>
<p>we'd need to have cfg available for codegen awareness</p>



<a name="213360481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360481">(Oct 14 2020 at 22:55)</a>:</h4>
<p>LLVM has a massive API surface area that I doubt we'll see replicated any time soon in cranelift</p>



<a name="213360561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360561">(Oct 14 2020 at 22:56)</a>:</h4>
<p>Will rustc ship with a variant of std compiled for cranelift?</p>



<a name="213360662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360662">(Oct 14 2020 at 22:57)</a>:</h4>
<p>that's not yet been decided, and certainly I don't expect that to be the case for some time on stable at least (nightly might be different)</p>



<a name="213360674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360674">(Oct 14 2020 at 22:58)</a>:</h4>
<p>I'm not sure that std needs to be compiled <em>for</em> cranelift though</p>



<a name="213360717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360717">(Oct 14 2020 at 22:58)</a>:</h4>
<p>afaik, abi wise llvm and cranelift should be compatible</p>



<a name="213360745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360745">(Oct 14 2020 at 22:58)</a>:</h4>
<p>iirc we don't currently ship llvm ir in std but I could be wrong</p>



<a name="213360753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360753">(Oct 14 2020 at 22:58)</a>:</h4>
<p>(maybe for LTO?)</p>



<a name="213360754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360754">(Oct 14 2020 at 22:58)</a>:</h4>
<p>Well, my thought is that we are using a large number of llvm intrinsics, and cfg won't help if it's only compiled once</p>



<a name="213360795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360795">(Oct 14 2020 at 22:59)</a>:</h4>
<p>to my recollection, everyone has been pretty opposed to cfg's on codegen backend</p>



<a name="213360808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360808">(Oct 14 2020 at 22:59)</a>:</h4>
<p>I hope that we can have Rust-level intrinsics that are uniform regardless of backend</p>



<a name="213360912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360912">(Oct 14 2020 at 23:00)</a>:</h4>
<p>Interesting.  My understanding was that the goal was to move away from platform-intrinsics towards llvm intrinsics, but maybe I got that wrong</p>



<a name="213360931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360931">(Oct 14 2020 at 23:00)</a>:</h4>
<p>well we're calling platform intrinsics that have llvm based names, so i sure don't expect cranelift to use those same names. And stdarch also has this issue.</p>



<a name="213360932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213360932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213360932">(Oct 14 2020 at 23:00)</a>:</h4>
<p>That may have also predated cranelift entirely</p>



<a name="213361098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361098">(Oct 14 2020 at 23:02)</a>:</h4>
<p>Reexporting vendor intrinsics through rustc instead of std seems monumental though maybe necessary</p>



<a name="213361157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361157">(Oct 14 2020 at 23:03)</a>:</h4>
<p>i don't know what you mean by that</p>



<a name="213361198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361198">(Oct 14 2020 at 23:03)</a>:</h4>
<p>I think it doesn't really matter where you have the facade, whether that's in rustc or in std it seems like about the same amount of code/pain?</p>



<a name="213361250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361250">(Oct 14 2020 at 23:04)</a>:</h4>
<p>(presuming we have roughly 1:1 compat anyway)</p>



<a name="213361276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361276">(Oct 14 2020 at 23:04)</a>:</h4>
<p>Well in std it's super easy since you can just link to LLVM.  Maybe it can be done just as easily in the compiler</p>



<a name="213361318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361318">(Oct 14 2020 at 23:05)</a>:</h4>
<p>not sure I follow, but it seems like it would be about equivalent</p>



<a name="213361332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361332">(Oct 14 2020 at 23:05)</a>:</h4>
<p>if it's in std, then std needs to have a cfg ability based on the codegen so that it knows what platform-intrinsics it can call or not. If letting people cfg based on codegen isn't something people want, then suddenly all of stdarch and stdsimd have to be based on work that's been injected to rustc, and then internally rustc needs to have the codegen cfg-ing happen there</p>



<a name="213361428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361428">(Oct 14 2020 at 23:06)</a>:</h4>
<p>but if we <em>do</em> just allow cfg based on codegenerator, then we don't need to move everything, we just need to add new versions of stuff in some places</p>



<a name="213361598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361598">(Oct 14 2020 at 23:08)</a>:</h4>
<p>One thing that makes the codegen in rustc a little non-trivial is that for cranelift it would need to do some codegen when lowering somewhere around HIR or MIR to generate implementations for things that LLVM provides in LLVM IR that cranelift might not</p>



<a name="213361631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361631">(Oct 14 2020 at 23:09)</a>:</h4>
<p>Certainly possible just something to keep in mind I think</p>



<a name="213361852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213361852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213361852">(Oct 14 2020 at 23:12)</a>:</h4>
<p>Yeah, I agree that there's definitely tradeoffs between the two. I would be very hesitant in needing to cfg(cranelift) though, for correctness (rather than performance or "cranelift just doesn't have atomics yet" etc)</p>



<a name="213362113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362113">(Oct 14 2020 at 23:16)</a>:</h4>
<p>So for portable SIMD I think we're probably going to end up using hundreds  of llvm intrinsics so it's probably more individual functions than something like atomics, but I'm not really sure</p>



<a name="213362116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362116">(Oct 14 2020 at 23:16)</a>:</h4>
<p>Well, for example, every single function <a href="https://github.com/rust-lang/stdarch/blob/master/crates/core_arch/src/x86/sse.rs#L1822">here</a> in stdarch is calling an llvm specific intrinsic. So either you need to be able to cfg around that, or every one of those has to go into rustc for rustc to resolve. And then repeat for every other module in stdarch, and then repeat for even more content in stdsimd.</p>
<p>For <code>stdarch</code> it's all in the "correctness" category. <code>stdsimd</code> could arguably make the case that it's a performance difference only.</p>



<a name="213362219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362219">(Oct 14 2020 at 23:17)</a>:</h4>
<p>I wonder if it would be possible to detect if you're using llvm intrinsics and only allow codegen to occur with llvm for that object file</p>



<a name="213362220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362220">(Oct 14 2020 at 23:18)</a>:</h4>
<p>Yeah. It seems like most of this wouldn't really matter too much whether the cfg is explicit in stdarch/simd or in rustc; it's about the same code regardless. Maybe I'm wrongt hough.</p>



<a name="213362502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362502">(Oct 14 2020 at 23:19)</a>:</h4>
<p>I personally feel strongly that we want to put in the work to avoid splitting any Rust code into "works on LLVM vs. works on cranelift" (or any other backend)</p>



<a name="213362508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362508">(Oct 14 2020 at 23:19)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> that "already happens", i'm assuming, because if you're on cranelift then it won't link</p>



<a name="213362614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362614">(Oct 14 2020 at 23:20)</a>:</h4>
<p>What I mean was even with a cranelift build, it would use llvm for stdarch and stdsimd, at least until cranelift supports those intrinsics</p>



<a name="213362619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362619">(Oct 14 2020 at 23:20)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> we could make <code>target_codegen</code> be perma-unstable. This is one place where i'd be fine with it being unstable because anything you'd want to be calling based on that cfg you can just complain that there's not a normal non-cfg'd intrinsic for it</p>



<a name="213362658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362658">(Oct 14 2020 at 23:21)</a>:</h4>
<p>oh sure yeah</p>



<a name="213362662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362662">(Oct 14 2020 at 23:21)</a>:</h4>
<p>I just mean that I don't want "stdsimd only works on LLVM"</p>



<a name="213362674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362674">(Oct 14 2020 at 23:21)</a>:</h4>
<p>if it lowers to non-simd, for example, on cranelift that seems fine</p>



<a name="213362758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362758">(Oct 14 2020 at 23:22)</a>:</h4>
<p>one challenge there is the ABI of vector types</p>



<a name="213362829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362829">(Oct 14 2020 at 23:23)</a>:</h4>
<p>that's a challenge with stdsimd implementing these vectors manually, i mean.</p>



<a name="213362852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362852">(Oct 14 2020 at 23:23)</a>:</h4>
<p>Would it be possible to write a support library that only gets used with cranelift, similar to something like libgcc?  It seems odd to put what is effectively just a library inside codegen (then again this is sounding a lot like just using cfg)</p>



<a name="213362958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213362958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213362958">(Oct 14 2020 at 23:24)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> until cranelift has real simd, makeing it all just be literal arrays using the array abi is "fine"</p>



<a name="213363003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363003">(Oct 14 2020 at 23:25)</a>:</h4>
<p>assuming you dont need to call code that uses the right ABI...</p>



<a name="213363117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363117">(Oct 14 2020 at 23:26)</a>:</h4>
<p>i don't think our stdsimd types are ffi safe in the general case. i agree it'd be a problem for stdarch though, so we should solve it once</p>



<a name="213363151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363151">(Oct 14 2020 at 23:26)</a>:</h4>
<p>Yeah, simd_ffi is an unstable feature</p>



<a name="213363189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363189">(Oct 14 2020 at 23:27)</a>:</h4>
<p>also if we call code in libstd that has been compiled with LLVM</p>



<a name="213363239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363239">(Oct 14 2020 at 23:27)</a>:</h4>
<p>would that... happen?</p>



<a name="213363323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363323">(Oct 14 2020 at 23:28)</a>:</h4>
<p>I think it is unclear at this point</p>



<a name="213363382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363382">(Oct 14 2020 at 23:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/257879-project-portable-simd/topic/cranelift.20backend/near/213360662">said</a>:</p>
<blockquote>
<p>that's not yet been decided, and certainly I don't expect that to be the case for some time on stable at least (nightly might be different)</p>
</blockquote>



<a name="213363405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363405">(Oct 14 2020 at 23:28)</a>:</h4>
<p>It might be desirable, though, because e.g. you might want std to be super optimized and your end-user code to be compiled by cranelift for compile time wins</p>



<a name="213363406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363406">(Oct 14 2020 at 23:28)</a>:</h4>
<p>rip</p>



<a name="213363432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363432">(Oct 14 2020 at 23:28)</a>:</h4>
<p>realistically imo the solution space of "use cranelift in rustc" is pretty unexplored at least to my knowledge right now</p>



<a name="213363442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363442">(Oct 14 2020 at 23:29)</a>:</h4>
<p>i.e., most questions are not answered or really discussed in too much detail</p>



<a name="213363476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363476">(Oct 14 2020 at 23:29)</a>:</h4>
<p>i think a relatively small amont of stdlib content would work out getting an llvm benefit though, since a whole ton of stdlib is generic and codegen'd in the using module</p>



<a name="213363490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363490">(Oct 14 2020 at 23:29)</a>:</h4>
<p>yeah that sounds like what we'd want. that said it might be reasonable for cranelift to be able to support a type which is ABI-compatible with vector types even if it has to be transmuted to an array to work on it</p>



<a name="213363575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363575">(Oct 14 2020 at 23:30)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> Yeah, sure. Though some of that might be mitigated by e.g. -Zshare-generics and (advanced) polymorphization that could e.g. intuit that Vec&lt;T&gt; is the same for all T of some size + alignment pairing or so</p>



<a name="213363585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363585">(Oct 14 2020 at 23:30)</a>:</h4>
<p>e.g. if they want to support vectorcall on windows they likely need that in some capacity (only up to sse2 though)</p>



<a name="213363695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213363695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213363695">(Oct 14 2020 at 23:32)</a>:</h4>
<p>til -Z share-generics — wanted that for ages</p>



<a name="213365052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213365052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213365052">(Oct 14 2020 at 23:52)</a>:</h4>
<p>i can't find the tracker for share-generics or why i wouldn't turn it on all the time</p>



<a name="213365082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213365082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213365082">(Oct 14 2020 at 23:53)</a>:</h4>
<p>It's also not listed in the unstable book's doc section on flags <a href="https://doc.rust-lang.org/unstable-book/compiler-flags.html">https://doc.rust-lang.org/unstable-book/compiler-flags.html</a></p>
<p>EDIT: huh -Z help shows that essentially none of these are lol</p>



<a name="213365278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213365278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213365278">(Oct 14 2020 at 23:56)</a>:</h4>
<p>"rust always has high quality documentation"</p>



<a name="213366000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366000">(Oct 15 2020 at 00:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/131828-t-compiler/topic/cranelift.20backend.20work/near/213358101">said</a>:</p>
<blockquote>
<p>I hope most if not all of the operations used by portable simd could use (newly introduced) <code>simd_*</code> platform intrinsics that are architecture and vector size independent. This would allow easy emulation of them implemented once per operation.</p>
</blockquote>
<p>Do these exist already, or are they an anticipated TODO?</p>



<a name="213366016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366016">(Oct 15 2020 at 00:08)</a>:</h4>
<p>I think shared generics can't be inlined or so? Not sure</p>



<a name="213366281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366281">(Oct 15 2020 at 00:13)</a>:</h4>
<p>Ah I didn't see that thread in t-compilers, didn't realize the plan is to go with platform-intrinsics.  We are definitely missing the majority of them</p>



<a name="213366384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366384">(Oct 15 2020 at 00:14)</a>:</h4>
<p>I thought the idea was explicitly <em>not</em> to use platform-intrinsics</p>



<a name="213366422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366422">(Oct 15 2020 at 00:15)</a>:</h4>
<p>Not sure if it's clear, platform-intrinsics is an ABI (?) provided by rustc, independent of LLVM</p>



<a name="213366428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366428">(Oct 15 2020 at 00:15)</a>:</h4>
<p>I Also Have Many Questions.</p>



<a name="213366535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366535">(Oct 15 2020 at 00:17)</a>:</h4>
<p>Ah, sorry, i may have mixed up which extern "..." was which</p>



<a name="213366551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366551">(Oct 15 2020 at 00:17)</a>:</h4>
<p>Yeah, it's definitely confusing</p>



<a name="213366556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366556">(Oct 15 2020 at 00:17)</a>:</h4>
<p><a href="https://github.com/rust-lang/stdsimd/blob/master/crates/core_simd/src/intrinsics.rs">https://github.com/rust-lang/stdsimd/blob/master/crates/core_simd/src/intrinsics.rs</a></p>



<a name="213366631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366631">(Oct 15 2020 at 00:18)</a>:</h4>
<p>I actually think moving to these would lower the complexity of stdsimd (and might actually be something rustc can do better than us)</p>



<a name="213366649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366649">(Oct 15 2020 at 00:18)</a>:</h4>
<p>Yeah, I thought that was the plan.</p>



<a name="213366675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366675">(Oct 15 2020 at 00:19)</a>:</h4>
<p>...OK,<br>
what <strong>actually</strong> are platform intrinsics?</p>



<a name="213366688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366688">(Oct 15 2020 at 00:19)</a>:</h4>
<p>In that case we may need to submit a lot of code to the compiler <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="213366695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366695">(Oct 15 2020 at 00:19)</a>:</h4>
<p>I think it's ironically the platform-independent ones, and not the platform-specific ones.</p>



<a name="213366701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366701">(Oct 15 2020 at 00:19)</a>:</h4>
<p>Haha, yeah.</p>



<a name="213366763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366763">(Oct 15 2020 at 00:20)</a>:</h4>
<p>They just lower to particular llvm instructions (and I guess cranelift in the future)</p>



<a name="213366783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366783">(Oct 15 2020 at 00:20)</a>:</h4>
<p>That said I think its unrealistic for us to ship this on time if we have to wait for platform intrinsics for unsupported operations tbh. I'm hopeful we won't need to add much to the compiler.</p>



<a name="213366798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366798">(Oct 15 2020 at 00:20)</a>:</h4>
<p>I tend to agree</p>



<a name="213366804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366804">(Oct 15 2020 at 00:21)</a>:</h4>
<p>It does seem that way, but speculation is not an explanation, ultimately.<br>
We know they lower to LLVM instructions, but technically right now that does not actually differentiate them from <strong>all Rust code</strong> that is not literal inline assembly.</p>



<a name="213366830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366830">(Oct 15 2020 at 00:21)</a>:</h4>
<p>Well isn't that the point?</p>



<a name="213366847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213366847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213366847">(Oct 15 2020 at 00:21)</a>:</h4>
<p>They lower to plain llvm just like normal rust code</p>



<a name="213367024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367024">(Oct 15 2020 at 00:24)</a>:</h4>
<p>They seem to be somewhat documented in RFC <a href="https://github.com/rust-lang/rust/issues/1199">#1199</a></p>



<a name="213367034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367034">(Oct 15 2020 at 00:24)</a>:</h4>
<p><a href="https://github.com/rust-lang/rfcs/blob/master/text/1199-simd-infrastructure.md">https://github.com/rust-lang/rfcs/blob/master/text/1199-simd-infrastructure.md</a></p>



<a name="213367038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367038">(Oct 15 2020 at 00:24)</a>:</h4>
<p>Is it? There is an<br>
0) abstract purpose for <code>extern "platform-intrinsics"</code><br>
1) technical design for <code>extern "platform-intrinsics"</code><br>
2) observed behavior for <code>"platform-intrinsics"</code></p>
<p>And also an<br>
3) abstract purpose for ordinary Rust code<br>
4) technical design for ordinary Rust code<br>
5) observed behavior for ordinary Rust code</p>
<p>In case 2 and 5, the behavior is to lower to LLVM instructions, but in case 4, the design is to lower to MIR and then output to "a codegen backend", and LLVM just happens to be the only one right now.</p>



<a name="213367065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367065">(Oct 15 2020 at 00:25)</a>:</h4>
<p>In case 1, we kiiinda mostly bypass MIR, as I understand it?</p>



<a name="213367081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367081">(Oct 15 2020 at 00:25)</a>:</h4>
<p>It appears to work that way</p>



<a name="213367135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367135">(Oct 15 2020 at 00:26)</a>:</h4>
<p>The RFC doesn't really discuss it but it looks like it goes all the way to codegen</p>



<a name="213367167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367167">(Oct 15 2020 at 00:27)</a>:</h4>
<p>I believe that's also how std::intrinsics works</p>



<a name="213367173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367173">(Oct 15 2020 at 00:27)</a>:</h4>
<p>mmh.</p>



<a name="213367228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367228">(Oct 15 2020 at 00:28)</a>:</h4>
<p>I don't really understand how the generics work (they're not really bounded, it somehow interacts with repr simd)</p>



<a name="213367268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367268">(Oct 15 2020 at 00:28)</a>:</h4>
<p>Also in case 3, I presumptively assume Rust's FE is mostly meant to be indifferent to LLVM: it's mostly a convenient optimizer.</p>



<a name="213367334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367334">(Oct 15 2020 at 00:29)</a>:</h4>
<p>It's definitely informed by llvm, but yeah I think so</p>



<a name="213367450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213367450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213367450">(Oct 15 2020 at 00:30)</a>:</h4>
<p>Right, we're dating but we're not exclusive. <span aria-label="crab" class="emoji emoji-1f980" role="img" title="crab">:crab:</span> <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span>  <span aria-label="dragon" class="emoji emoji-1f409" role="img" title="dragon">:dragon:</span></p>



<a name="213368109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213368109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213368109">(Oct 15 2020 at 00:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/257879-project-portable-simd/topic/cranelift.20backend/near/213362674">said</a>:</p>
<blockquote>
<p>if it lowers to non-simd, for example, on cranelift that seems fine</p>
</blockquote>
<p>Having non-simd lowering seems generally useful.  I could imagine some targets only using that, for example.</p>
<p>(No idea what the best way to pick it for cranelift would be, though.)</p>



<a name="213370608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213370608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213370608">(Oct 15 2020 at 01:25)</a>:</h4>
<p>So there was in fact originally a platform-intrinsics crate. In 2019 January, it was removed.</p>



<a name="213370689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213370689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213370689">(Oct 15 2020 at 01:26)</a>:</h4>
<p>Because the abstraction layer for implementing against LLVM was, at the time, perceived as unnecessary.</p>



<a name="213370775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213370775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213370775">(Oct 15 2020 at 01:28)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/57416">https://github.com/rust-lang/rust/pull/57416</a></p>



<a name="213370799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213370799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213370799">(Oct 15 2020 at 01:28)</a>:</h4>
<p>sounds like whoever said that has egg on their face now</p>



<a name="213370913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213370913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213370913">(Oct 15 2020 at 01:30)</a>:</h4>
<blockquote>
<p>This was originally attempted in <a href="https://github.com/rust-lang/rust/issues/57048">#57048</a> but it was realized that we<br>
could fully remove the crate via the "unadjusted" ABI on intrinsics.<br>
This means that all intrinsics in stdsimd are implemented directly<br>
against LLVM rather than using the abstraction layer provided here. That<br>
ends up meaning that this crate is no longer used at all.</p>
<p>This crate developed long ago to implement the SIMD intrinsics, but we<br>
didn't end up using it in the long run. In that case let's remove it!</p>
</blockquote>
<p><em>Technically</em> correct.</p>



<a name="213371397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213371397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213371397">(Oct 15 2020 at 01:41)</a>:</h4>
<p>Opened an ish. <a href="https://github.com/rust-lang/stdsimd/issues/40">https://github.com/rust-lang/stdsimd/issues/40</a></p>



<a name="213376108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213376108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213376108">(Oct 15 2020 at 03:13)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/labels/A-cranelift">rustc issues regarding Cranelift</a> includes a couple ones regarding refactoring rustc's codegen internals that will hopefully help inform this issue, like <a href="https://github.com/rust-lang/rust/issues/45274">https://github.com/rust-lang/rust/issues/45274</a> and <a href="https://github.com/rust-lang/rust/issues/56108">https://github.com/rust-lang/rust/issues/56108</a></p>



<a name="213376314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213376314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213376314">(Oct 15 2020 at 03:17)</a>:</h4>
<p>Also this <a href="https://github.com/rust-lang/rust/issues/77933">https://github.com/rust-lang/rust/issues/77933</a></p>



<a name="213382352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213382352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213382352">(Oct 15 2020 at 05:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/257879-project-portable-simd/topic/cranelift.20backend/near/213360674">said</a>:</p>
<blockquote>
<p>I'm not sure that std needs to be compiled <em>for</em> cranelift though</p>
</blockquote>
<p>Yes it needs to. There are abi incompatibilities that I need to fix.</p>



<a name="213388650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213388650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henri Sivonen <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213388650">(Oct 15 2020 at 07:31)</a>:</h4>
<p>It seems like a bad overall use of developer time to implement workarounds for cranelift in <code>core::simd</code>/<code>std::simd</code> as opposed to putting the work into implementing portable SIMD operations in cranelift (even if using ALU to begin with in order to have an ALU fallback on the cranelift side).</p>



<a name="213388891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213388891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henri Sivonen <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213388891">(Oct 15 2020 at 07:34)</a>:</h4>
<p>It also seems bad not to be able to make progress on portable SIMD due to cranelift not being ready. For that reason, I think it would be preferable to make <code>std::simd</code> unavailable for cranelift for now and treat resolving that as a blocker for stabilizing using cranelift as a back end as opposed to treating it as a blocker for <code>std::simd</code>. Adding a cranelift back end doesn't expand the expressiveness of <code>std</code> but <code>std::simd</code> does. In that sense, I think it's more important to let <code>std::simd</code> be unblocked than to let cranelift be unblocked.</p>



<a name="213388936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213388936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213388936">(Oct 15 2020 at 07:35)</a>:</h4>
<p><em>Even if</em> cranelift had a full SIMD support suite, we'd still need to either cfg in the crate source level between llvm calls and cranelift calls, or have the crate call a consistent api within rustc itself and then rustc calls either llvm or cranelift.</p>



<a name="213389025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213389025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213389025">(Oct 15 2020 at 07:36)</a>:</h4>
<p>But i agree, it should be a blocker to cranelift that it can't support <code>stdsimd</code>, not the other way around.</p>



<a name="213389124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213389124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henri Sivonen <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213389124">(Oct 15 2020 at 07:37)</a>:</h4>
<p>Right. Furthermore, a substantial part of the point of putting <code>std::simd</code> in the standard library is that it allows the implementation of <code>std::simd</code> to vary internally per back end. Creating a <code>rustc</code>-level abstraction over both LLVM and cranelift would just move where the abstraction layer is.</p>



<a name="213389264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213389264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henri Sivonen <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213389264">(Oct 15 2020 at 07:39)</a>:</h4>
<p>Arguably, moving the abstraction layer to <code>rustc</code> would make the abstraction layer even lower level and, therefore, likely more constraining for future changes than letting <code>core::simd</code>/<code>std::simd</code> be the committed-to abstraction layer.</p>



<a name="213390119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213390119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213390119">(Oct 15 2020 at 07:51)</a>:</h4>
<p>I <em>think</em> everyone is on the same page about the public api of stdsimd being the same across all targets and codegens</p>



<a name="213390142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213390142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213390142">(Oct 15 2020 at 07:51)</a>:</h4>
<p>The only part we're left to wonder about is if the llvm/cranelift split is crate internal or compiler internal</p>



<a name="213391748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213391748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213391748">(Oct 15 2020 at 08:09)</a>:</h4>
<p>Most <code>simd_*</code> platform intrinsics are directly translated to llvm intrinsics like <code>llvm.ceil.v2f32</code> by cg_llvm. It only applies a little bit of validation and infers the correct string for the <code>v2f32</code> part from the input type. The only <code>simd_*</code> intrinsics where this is not the case are those that directly use llvm instructions I think. Adding more <code>simd_*</code> intrinsics should be really easy. Because stdsimd should only use the platform independent llvm intrinsics I think, this means that everything stdsimd needs could be solved using <code>simd_*</code> intrinsics I think.</p>



<a name="213399988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213399988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henri Sivonen <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213399988">(Oct 15 2020 at 09:32)</a>:</h4>
<p>I think we should still allow for compile-time branches on compiler back end to work around back end bugs. For example, last I checked, <code>packed_simd</code> implements boolean reductions for ARMv7+NEON manually, because LLVM generated bad code for the reduction intrinsic. (Sure, the right way to fix would be to fix in LLVM, but it's impractical sometimes to wait for such fixes to propagate to rustc.)</p>



<a name="213400066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213400066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213400066">(Oct 15 2020 at 09:33)</a>:</h4>
<p>Could that workaround be implemented in cg_llvm?</p>



<a name="213400143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213400143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henri Sivonen <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213400143">(Oct 15 2020 at 09:34)</a>:</h4>
<p>Possibly. I'm not familiar enough with cg_llvm to say.</p>



<a name="213400285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213400285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henri Sivonen <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213400285">(Oct 15 2020 at 09:35)</a>:</h4>
<p>(The performance of boolean reductions on 32-bit ARM was the last blocker for Firefox to migrate from <code>simd</code> to <code>packed_simd</code>, which is why I happen to know about that hack.)</p>



<a name="213400360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213400360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213400360">(Oct 15 2020 at 09:36)</a>:</h4>
<p>While something like <code>#[cfg(codegen_backend)]</code> would work, it would require a PR to the respective project when cg_clif changes something, thus slowing down development.</p>



<a name="213458309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213458309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213458309">(Oct 15 2020 at 17:19)</a>:</h4>
<p>i don't understand why that cfg would place requirements on cranelift</p>



<a name="213458630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213458630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213458630">(Oct 15 2020 at 17:21)</a>:</h4>
<p>When using <code>#[cfg]</code> there would be a special code path for cg_clif. If I change cg_clif such that that code path doesn't work anymore I would have to wait for upstream to first change the code path before I can merge the cg_clif change.</p>



<a name="213458971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213458971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213458971">(Oct 15 2020 at 17:24)</a>:</h4>
<p>Ah, you're saying that <code>cg_clif</code> is a module in the main <code>rustc</code> repo, and so it and the appropriate rustc changes can all be one PR. i see</p>



<a name="213459030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213459030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213459030">(Oct 15 2020 at 17:24)</a>:</h4>
<p>No, that is not what I said.</p>



<a name="213459129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213459129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213459129">(Oct 15 2020 at 17:25)</a>:</h4>
<p>well, <em>either</em> rustc internals or stdsimd need to cfg based on cranelift or llvm, that's unavoidable</p>



<a name="213459159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213459159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213459159">(Oct 15 2020 at 17:25)</a>:</h4>
<p>so, given that, i'm not clear on what you're saying</p>



<a name="213459382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213459382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213459382">(Oct 15 2020 at 17:27)</a>:</h4>
<p>In the ideal case there would be a codegen backend independent set of intrinsics used by stdsimd. (<code>extern "platform-intrinsic" fn simd_*();</code>) Both cg_llvm and cg_clif each can then lower it in their own way.</p>



<a name="213459586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213459586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213459586">(Oct 15 2020 at 17:29)</a>:</h4>
<p>Ah, so cg_clif would actually get a message like "and now do simd_add", and it'd be a portable op name like that, then cg_clif would decide what to do with that internally? Okay, that makes sense</p>



<a name="213459763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213459763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213459763">(Oct 15 2020 at 17:30)</a>:</h4>
<p>Yes. <code>simd_add</code> and a couple of others already exist, but there are some operations for which there isn't any "platform-intrinsic" yet.</p>



<a name="213459809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213459809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213459809">(Oct 15 2020 at 17:30)</a>:</h4>
<p><a href="https://github.com/rust-lang/stdarch/blob/master/crates/core_arch/src/simd_llvm.rs">https://github.com/rust-lang/stdarch/blob/master/crates/core_arch/src/simd_llvm.rs</a></p>



<a name="213459931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213459931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213459931">(Oct 15 2020 at 17:31)</a>:</h4>
<p>right, i just thought that they got converted to codegen-specific operations <em>before</em> sending the info to the codegen. that's where the confusion was</p>



<a name="213461851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213461851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213461851">(Oct 15 2020 at 17:44)</a>:</h4>
<p>When stdsimd and cranelift are both in rustc but unstable, is it possible for them to be incompatible features?  Like you can use one but not both?  And then once both are mature enough they would be compatible (and eventually stable)</p>



<a name="213462137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213462137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213462137">(Oct 15 2020 at 17:46)</a>:</h4>
<p>I think that would help keep it from becoming a race to stabilization, because the compatibility would probably need to be resolved before it even gets to stabilization</p>



<a name="213462169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213462169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213462169">(Oct 15 2020 at 17:46)</a>:</h4>
<p>And could be done piecemeal</p>



<a name="213462341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213462341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213462341">(Oct 15 2020 at 17:47)</a>:</h4>
<p>That could work, but it would require me to patch libcore once again to remove the stdsimd include once stdsimd gets included in libcore.</p>



<a name="213462922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213462922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213462922">(Oct 15 2020 at 17:51)</a>:</h4>
<p>well, i think that your bigger concern is <code>stdarch</code></p>



<a name="213462956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213462956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213462956">(Oct 15 2020 at 17:51)</a>:</h4>
<p>because that's already stable</p>



<a name="213463398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213463398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213463398">(Oct 15 2020 at 17:53)</a>:</h4>
<p>Yeah. Just getting enough support for regex and rand was a pain. My hope is that by having stdsimd build on a non-infinite set of "platform-intrinsics" it would be a lot easier to support it. If most crates then switch to stdsimd, that pretty much solves the problem for me. Even if it is still possible to use stdarch.</p>



<a name="213464177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213464177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213464177">(Oct 15 2020 at 17:58)</a>:</h4>
<p>Right, I'm just suggesting we start with llvm intrinsics in stdsimd until we can PR all of the changes to rustc</p>



<a name="213468356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/213468356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#213468356">(Oct 15 2020 at 18:31)</a>:</h4>
<p>Sounds good!</p>



<a name="215190496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/215190496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#215190496">(Oct 31 2020 at 12:55)</a>:</h4>
<p>I’ve started looking into this properly for the MCP and a lot of the prior discussion is starting to make a lot more sense now 🙂 It looks like we’ve been back and forth on LLVM intrinsics for a couple years now, thanks for your patience and persistence in driving the needs of alternative backends over all that time <span class="user-mention" data-user-id="133247">@bjorn3</span>! It seems like <code>extern “platform-intrinsic”</code> is already a base to build off, we’re just missing a few <code>simd_*</code> intrinsics, right? I imagine we’ll be considering getting <code>stdsimd</code> into <code>nightly</code> blocked on replacing all of our direct LLVM intrinsics with <code>simd_*</code> ones? I wonder if that will fix our RISC-V issue too 😄</p>



<a name="215190803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/215190803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#215190803">(Oct 31 2020 at 13:02)</a>:</h4>
<blockquote>
<p>It seems like <code>extern “platform-intrinsic”</code> is already a base to build off, we’re just missing a few <code>simd_*</code> intrinsics, right?</p>
</blockquote>
<p>Yes. Over time I already have ported some of the vendor intrinsics in <code>core::arch</code> to use <code>extern "platform-intrinsics"</code>. Some of the remaining intrinsics either don't have a <code>platform-intrinsic</code> counterpart yet, are so specific to the respective arch that it likely won't ever get one, or for float intrinsics the <code>platform-intrinsic</code> counterpart behaves a bit differently in edge cases like NaN, denormals or negative zero. Except for the not yet existence of some <code>platform-intrinsic</code>s, none of the former problems should affect portable simd, as portable simd is roughly the common denominator between architectures and I expect won't guarantee that the behavior matches that of the native architecture.</p>



<a name="215569663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/215569663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#215569663">(Nov 04 2020 at 11:40)</a>:</h4>
<p>Opened an MCP: <a href="https://github.com/rust-lang/compiler-team/issues/381">https://github.com/rust-lang/compiler-team/issues/381</a></p>



<a name="215571230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/215571230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#215571230">(Nov 04 2020 at 12:00)</a>:</h4>
<p>Looks great to me!</p>



<a name="215676011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/215676011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#215676011">(Nov 05 2020 at 06:50)</a>:</h4>
<p>Discussion is happening over in <a class="stream-topic" data-stream-id="233931" href="/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/MCP.3A.20More.20Cranelift-friendly.20portable.20SIM.E2.80.A6.20compiler-team.23381">#t-compiler/major changes &gt; MCP: More Cranelift-friendly portable SIM… compiler-team#381</a></p>



<a name="247136313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247136313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247136313">(Jul 25 2021 at 17:38)</a>:</h4>
<p>As of <a href="https://github.com/bjorn3/rustc_codegen_cranelift/issues/1189">bjorn3/rustc_codegen_cranelift#1189</a> all integer tests of stdsimd pass with cg_clif.</p>



<a name="247136401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247136401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247136401">(Jul 25 2021 at 17:40)</a>:</h4>
<p>That is amazing news</p>



<a name="247136621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247136621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247136621">(Jul 25 2021 at 17:46)</a>:</h4>
<p>Is there a good guide somewhere with the list of cranelift instrinsics? Similar to the LLVM language reference?</p>



<a name="247136709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247136709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247136709">(Jul 25 2021 at 17:48)</a>:</h4>
<p>Cranelift doesn't have any intrinsics. It only has instructions. You can find the full list of instructions at <a href="https://docs.rs/cranelift-codegen/0.75.0/cranelift_codegen/ir/trait.InstBuilder.html">https://docs.rs/cranelift-codegen/0.75.0/cranelift_codegen/ir/trait.InstBuilder.html</a>. Many (theoretically) work on both integers and vectors. I say theoretically as it isn't implemented yet for certain instructions.</p>



<a name="247136832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247136832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247136832">(Jul 25 2021 at 17:51)</a>:</h4>
<p>That's exactly what I was looking for, thanks.  I was looking to add a byteswap intrinsic to rustc--at first glance doesn't look like there is one in cranelift (but of course it can be a shuffle).</p>



<a name="247136951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247136951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247136951">(Jul 25 2021 at 17:54)</a>:</h4>
<p>I'd be curious to see which float tests do not have the same -0 or NaN results, I think most of the tests should be flexible enough to allow variations of the correct result</p>



<a name="247137293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247137293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247137293">(Jul 25 2021 at 18:01)</a>:</h4>
<p>This is the cg_clif implementation of byteswap: <a href="https://github.com/bjorn3/rustc_codegen_cranelift/blob/356360836e128e1d1eb11caf6ff5186efb211960/src/intrinsics/mod.rs#L729-L807">https://github.com/bjorn3/rustc_codegen_cranelift/blob/356360836e128e1d1eb11caf6ff5186efb211960/src/intrinsics/mod.rs#L729-L807</a></p>



<a name="247137312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247137312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247137312">(Jul 25 2021 at 18:01)</a>:</h4>
<p>Sorry--I meant vector byteswap</p>



<a name="247137381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247137381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247137381">(Jul 25 2021 at 18:03)</a>:</h4>
<p>I know</p>



<a name="247137544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/cranelift%20backend/near/247137544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/cranelift.20backend.html#247137544">(Jul 25 2021 at 18:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/cranelift.20backend/near/247136951">said</a>:</p>
<blockquote>
<p>I'd be curious to see which float tests do not have the same -0 or NaN results, I think most of the tests should be flexible enough to allow variations of the correct result</p>
</blockquote>
<p>I mean in the presence of NaN some operations do or don't return the NaN.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>